# -*- coding: utf-8 -*-
from time import sleep
from common.driver import Driver
import allure
from common.page import Page
from config.config import Config
from regression_service_rdc.page_elements.el_main_rdc import main_rdc


class MainRdc:

    @allure.step('step:点击应用管理')
    def click_application_management(self):
        Page.click(main_rdc, '主目录', '应用管理')
        from regression_service_rdc.funtion.fun_application_management_rdc import ApplicationListRdc
        return ApplicationListRdc()

    @allure.step('step:点击分支管理')
    def click_branch_management(self):
        Page.click(main_rdc, '主目录', '分支管理')
        from regression_service_rdc.funtion.fun_branch_management_rdc import BranchManagementListRdc
        return BranchManagementListRdc()

    @allure.step('step:点击环境管理')
    def click_environment_management(self):
        Page.click(main_rdc, '主目录', '环境管理')
        from regression_service_rdc.funtion.fun_environment_rdc import EnvironmentListRdc
        return EnvironmentListRdc()

    @allure.step('step:选择项目')
    def click_select_project(self, data):
        """
        :param data: 填写需要输入的项目
        :return:
        """
        i = 0
        while i < 3:
            if Page.element(main_rdc, '顶行', '项目选择') is None:
                Page.page_refresh()
                i = i + 1
            else:
                sleep(0.5)
                break
        sleep(0.5)
        Page.click(main_rdc, '顶行', '项目选择')
        sleep(0.5)
        Page.send_key(main_rdc, '选择项目', '输入项目', data)
        sleep(0.5)
        Page.click(main_rdc, '选择项目', '选择项目')
        return self
